package equipmen

import (
	"API/client"
	"API/request"
	"API/response"
	equipment "equipment_server/proto"
	"github.com/gin-gonic/gin"
)

func BindDevice(c *gin.Context) {
	userId := c.GetUint("userId")
	var data request.BindDeviceRequest
	if err := c.ShouldBind(&data); err != nil {
		response.CurrencyErrResponse(c, 400, err.Error())
		return
	}
	res, err := client.BindDevice(c, &equipment.BindDeviceRequest{
		UserId:   int64(userId),
		DeviceId: data.DeviceId,
	})
	if err != nil {
		response.CurrencyErrResponse(c, -1, err.Error())
		return
	}
	response.CurrencySuccessResponse(c, res.Message, map[string]interface{}{"request_id": res.RequestId})
}
